package com.zero;

import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
	// write your code here
        //int(数据类型)[] arr(数组类型变量) = new int[10(数组的长度)];
        int [] arr1 = new int[5];
        arr1[0] = 17;
        arr1[1] = 16;
        arr1[2] = 15;
        arr1[3] = 12;
        arr1[4] = 34;
        System.out.println(Arrays.toString(arr1));

        double [] arr2 = {12.3, 14.5, 16.9, 22.4};
        System.out.println(Arrays.toString(arr2));
        System.out.println("arr1的长度："+arr1.length + " arr2的长度："+arr2.length);

        int sum1 = 0;
        for (int i :
                arr1) {
            System.out.print(i + " ");
            sum1 += i;
        }
        System.out.println("|arr1的和："+sum1);

        int sum2 = 0;
        for (int i = 0; i < arr2.length; i++) {
            System.out.print(arr2[i] + " ");
            sum2 += arr2[i];
        }
        System.out.println("|arr2的和："+sum2);
        Arrays.sort(arr1);
        System.out.println(Arrays.toString(arr1));
        System.out.println("元素12的index：" + Arrays.binarySearch(arr1,34));//index小于0元素不存在
        Arrays.fill(arr1,12);//把数组内的元素进行赋值
        System.out.println(Arrays.toString(arr1));


    }
}
